<?php

namespace frontend\models;

use yii\base\Model;
use yii\helpers\ArrayHelper;

class UserdetailForm extends Model {
	//属性
	//public $username;用户名
	public $RecMan;//收货人姓名
	public $Tel;//电话
	public $province;//省份
	public $city;//城市
	public $area;//地区
	public $address;//详细地址 
	public $PostCode;//邮政编码
	public $IsDefault;//是否默认
	
	public $PayAccountNo;//付款账号
	public $PayBank;//付款银行
	public $RecAccountNo;//收款账号
	public $RecBank;//收款银行
	public $TotalMoney;//充值总金额
	public $Remark;//备注
	
	public function rules(){
		return [
			//收货地址部分
			[['RecMan','Tel','province','city','address','PostCode'],'required','message'=>'{attribute}不能为空','on'=>'address'],
			[['province','city','area'],'exist','targetClass'=>City::className(),'targetAttribute'=>'region_id','message'=>'所选城市不存在','on'=>'address'],
			['Tel','match','pattern'=>'/(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}/','message'=>'电话格式不正确','on'=>'address'],
			['PostCode','integer','max'=>6,'min'=>6,'message'=>'邮政编码为6位数','on'=>'address'],
			//充值部分
			[['PayAccountNo','PayBank','TotalMoney'],'required','message'=>'{attribute}不能为空','on'=>'recharge'],
			['PayAccountNo','match','pattern'=>'/^(\d{16}|\d{19})$/','message'=>'付款银行账号输入错误','on'=>'recharge'],
			['TotalMoney','double','min'=>0.1,'message'=>'充值金额输入错误','on'=>'recharge'],
			//提现部分
			[['RecAccountNo','RecBank','TotalMoney'],'required','message'=>'{attribute}不能为空','on'=>'withdrawcash'],
			['RecAccountNo','match','pattern'=>'/^(\d{16}|\d{19})$/','message'=>'收款银行账号输入错误','on'=>'withdrawcash'],
			['TotalMoney','double','min'=>1,'message'=>'提现金额输入错误','on'=>'withdrawcash']
		];
	}
	
	public function scenarios(){
		return [
			'address'=>['RecMan','Tel','province','city','area','address','PostCode','IsDefault'],//收货地址场景
			'recharge'=>['PayAccountNo','PayBank','TotalMoney','Remark'],//充值场景
			'withdrawcash'=>['RecAccountNo','RecBank','TotalMoney','Remark']//提现场景
		];
	}
	
	public function attributeLabels(){
		return [
			'RecMan'=>'收货人姓名',
			'Tel'=>'固定电话',
			'province'=>'省份',
			'city'=>'城市',
			'area'=>'地区',
			'address'=>'详细地址',
			'PostCode'=>'邮政编码',
			'IsDefault'=>'是否默认',
			'PayAccountNo'=>'付款账号',
			'PayBank'=>'付款银行',
			'RecAccountNo'=>'收款账号',
			'RecBank'=>'收款银行',
			'TotalMoney'=>'总金额',
			'Remark'=>'备注'
		];
	}
	

	
	
}

?>


